//
//  IgnoreDeviceAlertViewController.swift
//  EasePods
//
//  Created by 易先生 on 2024/4/28.
//

import UIKit
import MoyoungLib

class IgnoreDeviceAlertViewController: ViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }
    
    override func makeUI() {
        super.makeUI()
        
        self.view.backgroundColor = R.color.common_2_bg_page()
        
        view.addSubview(titleLabel)
        view.addSubview(descLabel)
        view.addSubview(tipsImageView)
        view.addSubview(tipsLabel)
        view.addSubview(okButton)
        
        
        titleLabel.snp.makeConstraints { make in
            make.top.equalToSuperview().offset(60+kStatusBarHeight)
            make.leading.equalToSuperview().offset(34.0)
            make.centerX.equalToSuperview()
        }
        
        descLabel.snp.makeConstraints { make in
            make.top.equalTo(titleLabel.snp.bottom).offset(12.0)
            make.leading.equalTo(titleLabel.snp.leading)
            make.trailing.equalTo(titleLabel.snp.trailing)
        }
        
        tipsImageView.snp.makeConstraints { make in
            make.top.equalTo(descLabel.snp.bottom).offset(97)
            make.centerX.equalToSuperview()
        }
        
        tipsLabel.snp.makeConstraints { make in
            make.top.equalTo(tipsImageView.snp.bottom).offset(32)
            make.leading.equalToSuperview().offset(20)
            make.centerX.equalToSuperview()
        }
        
        okButton.snp.makeConstraints { make in
            make.height.equalTo(56)
            make.leading.equalToSuperview().offset(20)
            make.centerX.equalToSuperview()
            make.bottom.equalToSuperview().offset(-80.0)
        }
    }
    
    override func bindViewModel() {
        super.bindViewModel()
        okButton.rx.tap.subscribe(onNext: {[weak self] in
            guard let self = self else { return }
            self.dismissAction {
                BluetoothManager.shared.remove()
                let nav = NavigationController(rootViewController: BoundHomeViewController())
                RootViewManager.default.transition(vc: nav)
            }
        }).disposed(by: rx.disposeBag)
    }


    private lazy var titleLabel: Label = {
        let label = Label()
        label.font = Fonts.systemFont(ofSize: 24)
        label.text = R.string.localizable.device_remove_pair_hint()
        label.textColor = R.color.common_3_text()
        return label
    }()
    
    private lazy var descLabel: Label = {
        let label = Label()
        label.font = Fonts.systemFont(ofSize: 12)
        label.textColor = R.color.common_23_text_second()
        label.text = R.string.localizable.device_remove_pair_desc()
        return label
    }()
    
    private lazy var tipsImageView: ImageView = {
        let imageView = ImageView()
        imageView.image = R.image.img_bound_bluetooth()
        return imageView
    }()
    
    private lazy var tipsLabel: Label = {
        let label = Label()
        label.font = Fonts.systemFont(ofSize: 12)
        label.textColor = R.color.common_23_text_second()
        label.text = R.string.localizable.device_remove_pair_tips(Bundle.main.displayName ?? "")
        label.numberOfLines = 0
        label.textAlignment = .center
        return label
    }()
    
    private lazy var okButton: UIButton = {
        let agreeButton = UIButton()
        agreeButton.setTitle(R.string.localizable.common_confirm(), for: .normal)
        agreeButton.titleLabel?.font = Fonts.systemFont(ofSize: 16)
        agreeButton.backgroundColor = R.color.common_22_button_n()
        agreeButton.setTitleColor(R.color.common_24_button_text(), for: .normal)
        agreeButton.layer.cornerRadius = 6
        return agreeButton
    }()

}
